/**
 * @Author：ming
 * @Date：2023/10/2 8:26 PM
 * @Filename：Hj2
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author ming
 */
public class Hj2 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while ((str=br.readLine())!=null){
            int len = str.length();
            char[] cc = str.toLowerCase().toCharArray();
            char target = br.readLine().charAt(0);
            char c = Character.toLowerCase(target);
            int count = 0;
            for (int i = 0; i < cc.length; i++) {
                if(cc[i]==c){
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}
